package com.otupia.acs.locator;

import com.cvlep.appbase.locator.Locator;
import com.cvlep.appbase.locator.LocatorRouting;

public class LocatorRoutingImpl implements LocatorRouting 
{
	private final Locator _EJBLocator = new EJBLocator();
	private final Locator springLocator = new SpringLocator();
	private final Locator defaultLocator = this.springLocator;
	
	private static LocatorRoutingImpl locatorRouting = new LocatorRoutingImpl();
	
	public static LocatorRouting getInstance()
	{
		return LocatorRoutingImpl.locatorRouting;
	}
	
	@Override
	public Object getBean(String beanName) {
		return this.defaultLocator.getBean(beanName);
	}
	
	@Override
	public Object getBean(String beanName,String locatorName)
	{
		if("spring".equals(locatorName))
		{
			return this.springLocator.getBean(beanName);
		}
		else if("EJB".equals(locatorName))
		{
			return this._EJBLocator.getBean(beanName);
		}
		
		return this.getBean(beanName);
	}

}
